package com.stx.friends.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;


import com.stx.friends.dao.BloggerDao;
import com.stx.friends.entity.BloggerEntity;
import com.stx.friends.service.BloggerService;
import com.stx.friends.vo.BloggerVo;



public class BloggerServiceImpl implements BloggerService {

	private BloggerDao dao = null;
//查看博客的方法
	public List<BloggerVo> list(BloggerVo criteria) {

		List<BloggerVo> voList = new ArrayList<BloggerVo>();

		List<BloggerEntity> entityList = dao.list(criteria);

		for (BloggerEntity entity : entityList) {

			BloggerVo vo = new BloggerVo();

			// 对象属性值拷贝 entity => vo
			BeanUtils.copyProperties(entity, vo);

			voList.add(vo);

		}

		return voList;
	}

	

	public void setDao(BloggerDao dao) {
		this.dao = dao;
	}



	@Override
	public void delBlogger(String bid) {
		// TODO Auto-generated method stub
		dao.delBlogger(bid);
	}



	@Override
	public void addBlogger(BloggerVo blogger) {
		// TODO Auto-generated method stub
		dao.addBlogger(blogger);
	}






	@Override
	public BloggerVo getBloggerById(String bid) {
		BloggerEntity entity=new BloggerEntity();
		BloggerVo vo=new BloggerVo();
		entity=this.dao.getBloggerById(bid);
		BeanUtils.copyProperties(entity, vo);
		
		return vo;
	}



	@Override
	public List<BloggerVo> listLike(BloggerVo vo) {
		List<BloggerEntity> entitys=new ArrayList<BloggerEntity>();
		List<BloggerVo> voList = new ArrayList<BloggerVo>();
		entitys =this.dao.listLike(vo);
		for (BloggerEntity entity : entitys) {

			BloggerVo vo2 = new BloggerVo();

			// 对象属性值拷贝 entity => vo
			BeanUtils.copyProperties(entity, vo2);

			voList.add(vo2);

		}
		return voList;
	}



	@Override
	public void likeBlogger(String bid) {
		this.dao.likeBlogger(bid);
		
	}



	@Override
	public void unLikeBlogger(String bid) {
		this.dao.unLikeBlogger(bid);
	}



	@Override
	public void updateblogger(BloggerVo blogger) {
		this.dao.updateBlogger(blogger);
		
	}
	@Override
	public List<BloggerVo> listByUid(String wrxUid) {
		
		List<BloggerEntity> entitys=new ArrayList<BloggerEntity>();
		List<BloggerVo> voList = new ArrayList<BloggerVo>();
		entitys =this.dao.listByUid(wrxUid);
		if(entitys!=null){
			for (BloggerEntity entity : entitys) {
	
				BloggerVo vo2 = new BloggerVo();
	
				// 对象属性值拷贝 entity => vo
				BeanUtils.copyProperties(entity, vo2);
	
				voList.add(vo2);
	
			}
		}
		return voList;
	}



	

	

	



}
